package com.liuguang.picture.controller;

import com.liuguang.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

/**
 * @ClassName: FileController
 * @Description： 文件上传
 * @Author: wanghr
 * Date: 9:54 AM 2020/10/26
 * Version: 1.0
 */
@RestController
@RequestMapping("/file")
public class FileController {

    /**
     * 大文件分片上传，后端再合并文件
     */
    @RequestMapping("/test")
    public CommonResult uploadFile() throws FileNotFoundException {
        System.out.println("成功进入到图片微服务......");
//        String path = "/Users/liuguang/Desktop/a.txt";
//        File file = new File(path);
//        FileOutputStream fileOutputStream = new FileOutputStream(file);
//        FileChannel channel = fileOutputStream.getChannel();
//
//        RandomAccessFile rw = new RandomAccessFile(file, "rw");
//        rw.seek();

        return CommonResult.success("成功进入到图片微服务");
    }
}
